<%--                                                                       --%>
<%-- Copyright (c) 2003 BroadVision, Inc.  All rights reserved.            --%>
<%--                                                                       --%>
<%-- This software is copyrighted. Under the copyright laws, this software --%>
<%-- may not be copied, in whole or in part, without prior written consent --%>
<%-- of BroadVision, Inc. or its assignees. This software is provided      --%>
<%-- under the terms of a license between BroadVision and the recipient,   --%>
<%-- and its use is subject to the terms of that license.                  --%>
<%--                                                                       --%>
<%-- This software may be protected by one or more U.S. and International  --%>
<%-- patents.  Certain applications of BroadVision One-To-One software are --%>
<%-- covered by U.S. patent 5,710,887.                                     --%>
<%--                                                                       --%>
<%-- TRADEMARKS: BroadVision and BroadVision One-To-One are registered     --%>
<%-- trademarks of BroadVision, Inc., in the United States and the         --%>
<%-- European Community, and are trademarks of BroadVision, Inc., in other --%>
<%-- countries.  The BroadVision logo, is a trademark of BroadVision,      --%>
<%-- Inc., in the United States and other countries. Additionally, IONA    --%>
<%-- and Orbix are trademarks of IONA Technologies, Ltd.  RSA, MD5, and    --%>
<%-- RC2 are trademarks of RSA Data Security, Inc.                         --%>
<%--                                                                       --%>

<%@ page import = "java.util.*, java.net.*,
  com.broadvision.ssp.client.SelfServiceProcess,
  com.broadvision.ssp.client.*,
  com.broadvision.ssp.client.workflow.*,
  com.broadvision.ssp.util.TableConstants,
  com.broadvision.ssp.common.*"
%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ include file="/mc/common/encodeURL.jsp" %>

<SCRIPT language="javascript">
  var catoid = -1;
  var fromAction = "";
  var fromActionParam = "";
  function onSelection(param)
  {
    var firstSplit = param.split('&');
    var secondSplit = firstSplit[0].split('=');
    catoid = secondSplit[1];
    if (fromAction == "browseNewCategory") {
      doBrowseCategoryAction();
    }
    return true;
  }

  function browserProcessCategory()
  {
    var bparam = "contentTypeId=<%=TableConstants.SSP_PROCESS_CONTENT_TYPE%>&categoryID=0&rootNodeOID=0&action=expandCategory";
    if (<bean:write name="processForm" property="categoryOid"/> != 0) {
      bparam += "&currentNodeId=<bean:write name="processForm" property="categoryOid"/>";
    }
    var str = encodeURL('bp/categoryBrowser.do', bparam);
    var qualifier = window.open(str, "bpmCategoryPicker",
      "directories=no,height=300,width=450,left=50,top=50,resizable=yes,scrollbars=yes,location=no,menubar=no,status=no,toolbar=no,");
    if (qualifier != null) {
        if (qualifier.opener == null)
          qualifier.opener = self;
        qualifier.focus();
    }
  }

  function doReset(myform) {
    myform.action = '<html:rewrite page="/bp/processEdit.do"/>';
    myform.submit();
  }

  function doCancel(myform) {
    myform.action = '<html:rewrite page="/bp/processView.do"/>';
    myform.submit();
  }

  function doSave(myform) {
    if (myform.duration.value <= 0) {
      alert('<bean:message key="bp.process.error.invalidEstimatedDuration" bundle="bp.messages"/>');
      return;
    }
    if (validateProcessForm(myform)) {
      myform.forwardAction.value="/bp/processView.do";
      myform.action = '<html:rewrite page="/bp/processEditSave.do"/>';
      myform.submit();
    }
  }

  function browseNewCategory() {
    fromAction = "browseNewCategory";
    browserProcessCategory();
  }
  
  function doBrowseCategoryAction() {
    if (catoid != null && catoid != "") {
      document.processForm.categoryOid.value = catoid;
      document.processForm.action = '<html:rewrite page="/bp/processEditBrowse.do"/>';
      document.processForm.submit();
    }
  }

  function checkNumberOnly(e) {
    var charCode = (navigator.appName == "Netscape") ? e.which : e.keyCode;
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
      return false;
    }
    else {
      return true;
    }
  }

</SCRIPT>

<% 
  java.util.HashMap map = new java.util.HashMap();
  String procOid = request.getParameter("processOid"); 
  if (procOid != null && procOid.length() > 0) {
    map.put("processOid", procOid);
  }
  else {
    map.put("processOid", "-1");
  }
  pageContext.setAttribute("pagetabParam", map, PageContext.PAGE_SCOPE);
%>

<html:javascript formName="processForm"/>
<html:form action="/bp/processView.do">
<html:hidden name="processForm" property="processOid"/>
<html:hidden name="processForm" property="categoryOid"/>
<html:hidden name="processForm" property="managerAlias"/>
<html:hidden name="processForm" property="forwardAction"/>
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="content area">
  <tr>
    <td valign="top" width="100%">
      <div class="pageTitle"><bean:write name="processFormView" property="name"/></div>
      <div class="errorMessage"><html:errors bundle="bp.messages"/></div>
      <div><%@include file="/mc/common/pagetab.jsp" %></div>
      <logic:present name="processSubprocessPath" scope="session">
        <logic:greaterThan name="processSubprocessPath" property="processOid" value="0">
          <div class="breadcrumb">
            <bean:write name="processSubprocessPath" property="processName"/>
            <logic:iterate id="subprocess" name="processSubprocessPath" property="subprocesses" indexId="i">
              &nbsp;<bean:message key="bp.process.taskSeparator" bundle="bp.messages"/>&nbsp;
              <logic:equal name="subprocess" property="lastone" value="false">
                <bean:write name="subprocess" property="number"/>:
                <bean:write name="subprocess" property="friendlyName"/>
                &nbsp;<bean:message key="bp.process.taskSeparator" bundle="bp.messages"/>&nbsp;
                <bean:write name="subprocess" property="subprocessName"/>
              </logic:equal>
              <logic:equal name="subprocess" property="lastone" value="true">
                <bean:write name="subprocess" property="number"/>:
                <bean:write name="subprocess" property="friendlyName"/>
                &nbsp;<bean:message key="bp.process.taskSeparator" bundle="bp.messages"/>&nbsp;
                <bean:write name="subprocess" property="subprocessName"/>
              </logic:equal>
            </logic:iterate>
          </div>
        </logic:greaterThan>
      </logic:present>
      <div class="pageSubtitle">
        <span class="left"><bean:message key="bp.process.processView.information" bundle="bp.messages"/></span>
      </div> 
      <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Process summary">
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processName" bundle="bp.messages"/></td>
          <td class="labelField" width="70%"><bean:write name="processFormView" property="name"/></td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.packageName" bundle="bp.messages"/></td>
          <td class="labelField" width="70%"><bean:write name="processFormView" property="packageName"/></td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processView.description" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <html:textarea name="processForm" property="description" cols="31" rows="4"/>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processStatus" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <logic:equal name="processFormView" property="status" value="0">
              <bean:message key="bp.process.status.inDeployment" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processFormView" property="status" value="1">
              <logic:equal name="processFormView" property="packageOnline" value="true">
                <html:radio name="processForm" property="online" value="true"/>
                <bean:message key="bp.process.status.online" bundle="bp.messages"/>&nbsp;
                <html:radio name="processForm" property="online" value="false"/>
                <bean:message key="bp.process.status.offline" bundle="bp.messages"/>
              </logic:equal>
              <logic:equal name="processFormView" property="packageOnline" value="false">
                <logic:equal name="processForm" property="online" value="true">
                  <bean:message key="bp.process.status.online" bundle="bp.messages"/>
                </logic:equal>
                <logic:equal name="processForm" property="online" value="false">
                  <bean:message key="bp.process.status.offline" bundle="bp.messages"/>
                </logic:equal>
              </logic:equal>
            </logic:equal>
            <logic:equal name="processFormView" property="status" value="2">
              <bean:message key="bp.process.status.error" bundle="bp.messages"/>
            </logic:equal>
            <logic:equal name="processFormView" property="status" value="3">
              <bean:message key="bp.process.status.toBeConfigured" bundle="bp.messages"/>
            </logic:equal>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processManager" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <logic:notEmpty name="processFormView" property="managerFullName">
              <bean:write name="processFormView" property="managerFullName"/>
            </logic:notEmpty>
            <logic:empty name="processFormView" property="managerFullName">
              &nbsp;
            </logic:empty>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processView.categoryPath" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <logic:empty name="processFormView" property="paths">
              <bean:message key="bp.process.processView.notCategorized" bundle="bp.messages"/>
            </logic:empty>
            <logic:notEmpty name="processFormView" property="paths">
              <bean:message key="bp.process.processBrowse.rootCategory" bundle="bp.messages"/>
              <logic:iterate id="path" name="processFormView" property="paths" indexId="i">
                &nbsp;<bean:message key="bp.process.pathSeparator" bundle="bp.messages"/>&nbsp;
                <bean:write name="path" property="name"/>
              </logic:iterate>
            </logic:notEmpty>
            <logic:equal name="processFormView" property="editCategory" value="true">
              &nbsp;
              <input type="button" name="browseCategory" class="pageButton" 
                onClick="browseNewCategory();" 
                value='<bean:message key="button.browse" bundle="bp.messages"/>'>
            </logic:equal>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processView.estimatedDuration" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <html:text name="processForm" property="duration" size="5" maxlength="5" onkeypress="return checkNumberOnly(event)"/>
            &nbsp;
            <html:select name="processForm" property="durationType" size="1">
              <html:option key="bp.process.type.workingHours" value="0" bundle="bp.messages"/>
              <html:option key="bp.process.type.clockHours" value="1" bundle="bp.messages"/>
              <html:option key="bp.process.type.workingDays" value="2" bundle="bp.messages"/>
              <html:option key="bp.process.type.calendarDays" value="3" bundle="bp.messages"/>
            </html:select>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processView.priority" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <html:radio name="processForm" property="priority" value="1"/>
            <bean:message key="bp.process.processView.priority.high" bundle="bp.messages"/>
            &nbsp;
            <html:radio name="processForm" property="priority" value="2"/>
            <bean:message key="bp.process.processView.priority.medium" bundle="bp.messages"/>
            &nbsp;
            <html:radio name="processForm" property="priority" value="3"/>
            <bean:message key="bp.process.processView.priority.low" bundle="bp.messages"/>
          </td>
        </tr>
        <tr> 
          <td class="label" width="30%"><bean:message key="bp.process.processView.version" bundle="bp.messages"/></td>
          <td class="labelField" width="70%">
            <bean:write name="processFormView" property="version"/>
          </td>
        </tr>
      </table>
      <div class="pageButtonWrap" align="right">
        <input type="button" name="resetData" class="pageButton" 
          onClick="doReset(this.form);" 
          value='<bean:message key="button.reset" bundle="bp.messages"/>'>
        &nbsp;
        <input type="button" name="cancelData" class="pageButton" 
          onClick="doCancel(this.form);" 
          value='<bean:message key="button.cancel" bundle="bp.messages"/>'>
        <input type="button" name="saveData" class="pageButton" 
          onClick="doSave(this.form);" 
          value='<bean:message key="button.save" bundle="bp.messages"/>'>
      </div>
    </td>
  </tr>
</table>
</html:form>

